package com.abcdefg.lotterysystem.common.utils;

import java.util.Random;

public class CaptchaUtils {
    /**
     * 生成验证码
     * @return
     */
    public static String  createCaptcha(int n) {
        String code = generateCode(n);
        return code;
    }
    private static String generateCode(int length) {
        String characters = "0123456789";
        Random random = new Random();
        StringBuilder code = new StringBuilder();

        for (int i = 0; i < length; i++) {
            int index = random.nextInt(characters.length());
            code.append(characters.charAt(index));
        }
        return code.toString();
    }
}
